Skip to content

refactor: name the record views after what they are - #1020

Merged
vbreuss merged 1 commit into
mainfrom
refactor/rename-record-views
Nov 18, 2026
Merged

vbreuss merged 1 commit into
mainfrom
refactor/rename-record-views

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 18, 2026

Copy link
Copy Markdown
Member

The Fast*Buffer types no longer buffer anything since all calls of a mock are recorded in one list: each is a static recorder plus a stateless view on the records of one member. Their names and doc comments still described storage per member, which made the recording path harder to follow than it is.

The types are now called MethodRecords<...>, PropertyGetterRecords, IndexerGetterRecords<...>, EventRecords and so on, with MemberRecords as their base. This is a rename only; the generated code changes in the renamed identifiers and nothing else.

@vbreuss vbreuss self-assigned this Nov 18, 2026
@vbreuss
vbreuss added this pull request to stack #1018 November 18, 2026 13:07
@vbreuss
vbreuss force-pushed the refactor/rename-record-views branch 5 times, most recently from 321195d to eb1e628 Compare November 18, 2026 13:29
Base automatically changed from refactor/record-position-as-int to main November 18, 2026 13:29
The `Fast*Buffer` types no longer buffer anything since all calls of a mock are recorded in one list: each is a static recorder plus a stateless view on the records of one member. Their names and doc comments still described storage per member, which made the recording path harder to follow than it is.

The types are now called `MethodRecords<...>`, `PropertyGetterRecords`, `IndexerGetterRecords<...>`, `EventRecords` and so on, with `MemberRecords` as their base. This is a rename only; the generated code changes in the renamed identifiers and nothing else.
@vbreuss
vbreuss force-pushed the refactor/rename-record-views branch from eb1e628 to e47a328 Compare November 18, 2026 13:34
@vbreuss
vbreuss merged commit 1c7ba75 into main Nov 18, 2026
19 of 20 checks passed
@vbreuss
vbreuss deleted the refactor/rename-record-views branch November 18, 2026 13:35
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🚀 Benchmark Results

Compared to main @​ 3ef709c6: memory to the latest run, time to the median of the last 10 runs, as the runners differ in speed. A relative change marks when Mockolate gets more than 15% faster or slower relative to Imposter and TUnitMocks: 🔴 / 🟢 against both of them, 🔸 / 🔹 against only one.

CallbackBenchmarks

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Callback 0.90× → 1.11× 🔹 -19% 2.23× → 2.39×
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Callback 208.6 ns → 166.7 ns (-20%) 792 B → 792 B 0.90× → 1.11× 🔹 -19% 2.23× → 2.39×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6975P-C 3.49GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Callback Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 166.7 ns 6.24 ns 5.83 ns 1.00 792 B 1.00
Imposter 184.6 ns 8.13 ns 7.60 ns 1.11 616 B 0.78
TUnitMocks 398.0 ns 8.08 ns 7.56 ns 2.39 2056 B 2.60
Moq 36,454.2 ns 192.09 ns 170.29 ns 218.88 9198 B 11.61
NSubstitute 3,248.6 ns 66.45 ns 62.15 ns 19.51 7864 B 9.93
FakeItEasy 2,867.6 ns 97.11 ns 90.83 ns 17.22 6924 B 8.74

CompleteEventBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Event 159.0 ns → 187.2 ns (+18%) 696 B → 696 B 1.06× → 1.09× 1.05× → 0.98×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 2.62GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Event Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 187.2 ns 7.54 ns 7.05 ns 1.00 696 B 1.00
Imposter 203.5 ns 1.62 ns 1.52 ns 1.09 512 B 0.74
TUnitMocks 183.4 ns 11.25 ns 10.52 ns 0.98 1392 B 2.00
Moq 14,937.6 ns 265.92 ns 235.73 ns 79.90 12761 B 18.33
NSubstitute 5,716.7 ns 30.24 ns 25.25 ns 30.58 9192 B 13.21
FakeItEasy 212,386.7 ns 1,707.26 ns 1,596.97 ns 1,136.10 15586 B 22.39

CompleteIndexerBenchmarks

Memory

Benchmark main PR Δ
Indexer (N=1000) 105,545 B 105,544 B 🟢 -1 B (±0%)

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Indexer (N=1) 0.53× → 0.74× 🟢 -29% 1.36× → 1.75× 🟢 -22%
Indexer (N=10) 0.36× → 0.66× 🟢 -46% 1.19× → 2.08× 🟢 -43%
Indexer (N=1000) 0.28× → 0.60× 🟢 -53% 1.12× → 2.17× 🟢 -48%
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Indexer (N=1) 458.6 ns → 323.0 ns (-30%) 1,648 B → 1,648 B 0.53× → 0.74× 🟢 -29% 1.36× → 1.75× 🟢 -22%
Indexer (N=10) 1.62 μs → 889.7 ns (-45%) 2,584 B → 2,584 B 0.36× → 0.66× 🟢 -46% 1.19× → 2.08× 🟢 -43%
Indexer (N=1000) 124.61 μs → 65.13 μs (-48%) 105,545 B → 105,544 B 0.28× → 0.60× 🟢 -53% 1.12× → 2.17× 🟢 -48%
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Indexer N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 323.0 ns 5.20 ns 4.86 ns 1.00 1.61 KB 1.00
Imposter 1 238.1 ns 0.79 ns 0.62 ns 0.74 1.07 KB 0.67
TUnitMocks 1 564.0 ns 2.89 ns 2.70 ns 1.75 2.72 KB 1.69
Moq 1 141,230.2 ns 1,526.87 ns 1,428.24 ns 437.31 20.32 KB 12.62
NSubstitute 1 6,933.2 ns 51.59 ns 48.25 ns 21.47 12.73 KB 7.91
FakeItEasy 1 6,995.6 ns 41.01 ns 36.36 ns 21.66 13.27 KB 8.25
Mockolate 10 889.7 ns 3.66 ns 3.05 ns 1.00 2.52 KB 1.00
Imposter 10 588.6 ns 8.14 ns 7.61 ns 0.66 2.13 KB 0.84
TUnitMocks 10 1,854.0 ns 26.03 ns 24.35 ns 2.08 5.37 KB 2.13
Moq 10 151,006.8 ns 668.10 ns 557.90 ns 169.74 29.69 KB 11.77
NSubstitute 10 17,776.4 ns 261.04 ns 244.18 ns 19.98 25.52 KB 10.11
FakeItEasy 10 15,593.7 ns 174.82 ns 163.53 ns 17.53 32.47 KB 12.87
Mockolate 1000 65,130.2 ns 539.78 ns 504.91 ns 1.00 103.07 KB 1.00
Imposter 1000 38,949.1 ns 253.01 ns 236.66 ns 0.60 118.15 KB 1.15
TUnitMocks 1000 141,441.5 ns 2,817.18 ns 2,635.19 ns 2.17 293.67 KB 2.85
Moq 1000 762,125.7 ns 8,535.40 ns 7,566.41 ns 11.70 1006.45 KB 9.76
NSubstitute 1000 1,252,889.9 ns 28,067.78 ns 26,254.62 ns 19.24 1465.59 KB 14.22
FakeItEasy 1000 1,126,859.8 ns 45,636.82 ns 42,688.71 ns 17.30 2153 KB 20.89

CompleteMethodBenchmarks

✅ No changes in memory or relative performance (3 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Method (N=1) 125.7 ns → 113.4 ns (-10%) 600 B → 600 B 1.13× → 1.27× 2.93× → 3.24×
Method (N=10) 325.2 ns → 296.5 ns (-9%) 1,104 B → 1,104 B 0.90× → 0.97× 3.30× → 3.66×
Method (N=1000) 22.51 μs → 21.15 μs (-6%) 56,544 B → 56,544 B 0.77× → 0.82× 3.59× → 3.74×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Method N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 113.4 ns 1.85 ns 1.73 ns 1.00 600 B 1.00
Imposter 1 143.8 ns 2.46 ns 2.30 ns 1.27 728 B 1.21
TUnitMocks 1 367.0 ns 6.40 ns 5.99 ns 3.24 2088 B 3.48
Moq 1 114,337.8 ns 410.92 ns 364.27 ns 1,008.22 14914 B 24.86
NSubstitute 1 4,643.2 ns 56.14 ns 52.51 ns 40.94 9320 B 15.53
FakeItEasy 1 4,282.2 ns 56.53 ns 52.88 ns 37.76 8160 B 13.60
Mockolate 10 296.5 ns 5.11 ns 4.53 ns 1.00 1104 B 1.00
Imposter 10 288.1 ns 4.94 ns 4.62 ns 0.97 1088 B 0.99
TUnitMocks 10 1,085.9 ns 20.99 ns 19.63 ns 3.66 3840 B 3.48
Moq 10 117,918.4 ns 606.48 ns 567.30 ns 397.73 18906 B 17.12
NSubstitute 10 6,862.8 ns 122.83 ns 102.56 ns 23.15 12344 B 11.18
FakeItEasy 10 6,786.1 ns 231.90 ns 216.92 ns 22.89 16394 B 14.85
Mockolate 1000 21,150.5 ns 266.13 ns 248.94 ns 1.00 56544 B 1.00
Imposter 1000 17,354.0 ns 114.57 ns 101.56 ns 0.82 40688 B 0.72
TUnitMocks 1000 79,053.0 ns 917.03 ns 857.79 ns 3.74 203585 B 3.60
Moq 1000 288,386.9 ns 2,673.70 ns 2,500.98 ns 13.64 431938 B 7.64
NSubstitute 1000 240,395.3 ns 2,492.98 ns 2,209.97 ns 11.37 378038 B 6.69
FakeItEasy 1000 302,942.2 ns 4,139.45 ns 3,872.04 ns 14.32 944402 B 16.70

CompletePropertyBenchmarks

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Property (N=10) 0.50× → 0.58× 🟢 -15% 2.39× → 2.94× 🟢 -19%
Property (N=1000) 0.37× → 0.49× 🟢 -24% 2.59× → 3.10× 🟢 -17%
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Property (N=1) 241.1 ns → 252.8 ns (+5%) 904 B → 904 B 0.62× → 0.68× 1.63× → 1.69×
Property (N=10) 601.5 ns → 577.5 ns (-4%) 1,768 B → 1,768 B 0.50× → 0.58× 🟢 -15% 2.39× → 2.94× 🟢 -19%
Property (N=1000) 43.27 μs → 39.13 μs (-10%) 96,808 B → 96,808 B 0.37× → 0.49× 🟢 -24% 2.59× → 3.10× 🟢 -17%
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6975P-C 3.43GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Property N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 252.8 ns 1.86 ns 1.65 ns 1.00 904 B 1.00
Imposter 1 173.0 ns 1.85 ns 1.55 ns 0.68 672 B 0.74
TUnitMocks 1 428.2 ns 3.48 ns 3.25 ns 1.69 1672 B 1.85
Moq 1 6,971.0 ns 31.40 ns 26.22 ns 27.58 10568 B 11.69
NSubstitute 1 5,241.6 ns 29.39 ns 26.06 ns 20.74 11664 B 12.90
FakeItEasy 1 4,777.8 ns 43.22 ns 40.43 ns 18.90 11191 B 12.38
Mockolate 10 577.5 ns 2.58 ns 2.41 ns 1.00 1768 B 1.00
Imposter 10 337.1 ns 4.05 ns 3.39 ns 0.58 960 B 0.54
TUnitMocks 10 1,698.5 ns 9.44 ns 8.83 ns 2.94 4024 B 2.28
Moq 10 11,727.5 ns 41.03 ns 36.37 ns 20.31 18504 B 10.47
NSubstitute 10 11,644.7 ns 47.87 ns 44.77 ns 20.17 21528 B 12.18
FakeItEasy 10 12,659.3 ns 68.51 ns 64.09 ns 21.92 30780 B 17.41
Mockolate 1000 39,131.2 ns 160.35 ns 149.99 ns 1.00 96808 B 1.00
Imposter 1000 19,089.0 ns 176.40 ns 165.01 ns 0.49 32640 B 0.34
TUnitMocks 1000 121,367.2 ns 533.32 ns 498.87 ns 3.10 242489 B 2.50
Moq 1000 456,602.5 ns 2,317.69 ns 2,054.57 ns 11.67 836449 B 8.64
NSubstitute 1000 691,642.9 ns 3,004.57 ns 2,810.47 ns 17.68 1139620 B 11.77
FakeItEasy 1000 864,989.7 ns 13,400.34 ns 12,534.69 ns 22.11 2194285 B 22.67

CompleteUnconfiguredBenchmarks

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Unconfigured (N=1) 0.44× → 0.60× 🟢 -25% 0.91× → 1.16× 🟢 -21%
Unconfigured (N=10) 0.45× → 0.57× 🟢 -22% 1.50× → 1.87× 🟢 -20%
Unconfigured (N=1000) 0.44× → 0.61× 🟢 -28% 1.70× → 2.17× 🟢 -21%
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Unconfigured (N=1) 543.9 ns → 494.8 ns (-9%) 1,512 B → 1,512 B 0.44× → 0.60× 🟢 -25% 0.91× → 1.16× 🟢 -21%
Unconfigured (N=10) 2.12 μs → 1.93 μs (-9%) 3,984 B → 3,984 B 0.45× → 0.57× 🟢 -22% 1.50× → 1.87× 🟢 -20%
Unconfigured (N=1000) 166.95 μs → 153.59 μs (-8%) 273,265 B → 273,265 B 0.44× → 0.61× 🟢 -28% 1.70× → 2.17× 🟢 -21%
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 2.61GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Unconfigured N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 494.8 ns 15.27 ns 12.75 ns 1.00 1.48 KB 1.00
Imposter 1 294.8 ns 5.24 ns 4.90 ns 0.60 1.06 KB 0.72
TUnitMocks 1 573.3 ns 4.87 ns 4.32 ns 1.16 1.81 KB 1.23
Moq 1 117,149.2 ns 1,034.26 ns 916.84 ns 236.90 9.79 KB 6.63
NSubstitute 1 7,621.4 ns 68.70 ns 60.90 ns 15.41 10.01 KB 6.78
FakeItEasy 1 7,899.2 ns 103.31 ns 96.64 ns 15.97 11.58 KB 7.84
Mockolate 10 1,926.1 ns 19.46 ns 18.20 ns 1.00 3.89 KB 1.00
Imposter 10 1,103.8 ns 18.25 ns 17.07 ns 0.57 2.89 KB 0.74
TUnitMocks 10 3,593.1 ns 48.19 ns 45.07 ns 1.87 8.47 KB 2.18
Moq 10 133,164.6 ns 1,048.00 ns 980.30 ns 69.14 24.53 KB 6.30
NSubstitute 10 23,540.5 ns 73.16 ns 64.85 ns 12.22 22.93 KB 5.89
FakeItEasy 10 30,648.3 ns 217.38 ns 203.34 ns 15.91 53.92 KB 13.86
Mockolate 1000 153,585.7 ns 627.11 ns 523.66 ns 1.00 266.86 KB 1.00
Imposter 1000 93,605.3 ns 684.14 ns 639.94 ns 0.61 203.99 KB 0.76
TUnitMocks 1000 332,513.8 ns 4,386.42 ns 4,103.06 ns 2.17 691.21 KB 2.59
Moq 1000 1,609,013.1 ns 16,931.02 ns 15,837.28 ns 10.48 1653.01 KB 6.19
NSubstitute 1000 1,734,032.7 ns 12,984.82 ns 12,146.01 ns 11.29 1434.49 KB 5.38
FakeItEasy 1000 3,107,559.9 ns 68,723.86 ns 64,284.34 ns 20.23 4690.81 KB 17.58

CompleteWorkflowBenchmarks

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Complete 0.92× → 0.77× 🔴 +19% 2.86× → 2.34× 🔴 +22%
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Complete 999.8 ns → 1.53 μs (+53%) 2,872 B → 2,872 B 0.92× → 0.77× 🔴 +19% 2.86× → 2.34× 🔴 +22%
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 3.12GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Complete Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1.529 μs 0.0291 μs 0.0272 μs 1.00 2.8 KB 1.00
Imposter 1.181 μs 0.0125 μs 0.0111 μs 0.77 3.17 KB 1.13
TUnitMocks 3.577 μs 0.0378 μs 0.0335 μs 2.34 10.3 KB 3.67
Moq 549.612 μs 2.5858 μs 2.4187 μs 359.63 46.28 KB 16.50
NSubstitute 26.457 μs 0.1328 μs 0.1243 μs 17.31 37.13 KB 13.24
FakeItEasy 24.829 μs 0.1965 μs 0.1641 μs 16.25 34.23 KB 12.20

MockCreationBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
CreateMock 15.7 ns → 14.2 ns (-10%) 136 B → 136 B 5.49× → 5.93× 1.64× → 1.81×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
INTEL XEON PLATINUM 8573C 3.48GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

CreateMock Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 14.18 ns 0.457 ns 0.427 ns 1.00 136 B 1.00
Imposter 84.06 ns 1.106 ns 1.035 ns 5.93 504 B 3.71
TUnitMocks 25.60 ns 0.225 ns 0.200 ns 1.81 216 B 1.59
Moq 952.77 ns 22.043 ns 20.619 ns 67.25 2088 B 15.35
NSubstitute 1,313.92 ns 17.267 ns 16.152 ns 92.74 5032 B 37.00
FakeItEasy 1,126.10 ns 35.365 ns 33.080 ns 79.48 2751 B 20.23

github-actions Bot added a commit that referenced this pull request Nov 18, 2026
github-actions Bot added a commit that referenced this pull request Nov 18, 2026
@github-actions

Copy link
Copy Markdown

This is addressed in release v4.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant